<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>        
        <title></title>
        <meta http-equiv="content-type" content="text/htm;charset=utf-8"/>
        {css file="__PUBLIC__/admin/css/common.css" /}
        {jquery/}
        <script>
            $(function(){
                $('tr').mouseover(function(){
                    $(this).css('background-color','#f6f6f6');
                }).mouseout(function(){
                    $(this).css('background-color','#fff');
                });
            });
        </script>
</head>
<body>
<div id="hd_jqueryui_div"></div>
<ul class="top_title">
    <li>
        <p class="menu_title">栏目管理</p>
    </li>
    <li>|</li>
    <li>
        <a class="menu_title_a" >
            &nbsp;栏目列表
        </a>
    </li>
</ul>
<form action="__APP__/index/sort" method="post">
    <table class="table">
        <thead>
            <tr class="top_channel">
                <th align="center" width="60">ID</th>
                <!-- <th align="center" width="100">排序</th> -->
                <th align="left" style="padding-left:95px;" width="26%">栏目名称</th>
                <!-- <th align="center" width="100">父级栏目</th> -->
                <!-- <th align="center" width="100">是否显视</th> -->
                <!-- <th align="center" width="100">是否飘红</th> -->
                <th align="center" width="160">管理栏目</th>
                <th align="center">操作</th>
            </tr>
        </thead>
        <tbody>
            <?php $i = 1;?>
        <foreach from="$channel" value="$v">
            <tr class="top_channel">
                <td align="center">
                    <input type="text" disabled="disabled" value="1" class="input-mini"/>
                </td>
                <!-- <td align="center">
                    <input type="text" class="input-mini" value="{$v.sort}" name="sort[{$v.id}]"/>
                </td> -->
                <td align="left" style="padding-left:85px;">
                    <strong index="{$i}" style="font-weight: lighter;cursor: pointer;color: #3A66B0;">
                        <i class="icon icon-plus"></i>&nbsp;新闻中心
                    </strong>
                </td>
                <td align="center">
                    <a href="__CONTROL__/addChannel?id={$v.id}" style="color:#1E90FF;">
                        <i class="icon icon-plus-sign"></i>&nbsp;添加子栏目</a>
                </td>
                <td align="center">
                    <a href="__CONTROL__/updateChannel?id={$v.id}" class="btn edit">
                        <i class="icon icon-edit"></i>&nbsp;修改
                    </a>&nbsp;
                    <!-- <a href="__CONTROL__/updateChannel?id={$v.id}" class="btn edit">
                        <i class="icon icon-edit"></i>&nbsp;添加文章
                    </a>&nbsp; -->
                    <a href="__CONTROL__/delChannel?id={$v.id}" class="isok btn del">
                        <i class="icon icon-trash"></i>&nbsp;删除
                    </a>
                </td>
            </tr>
            <foreach from="$v['child']" value="$s">
                <tr class="child_channel_{$i}" style="display: none;">
                    <td align="center">2</td>
                    <td align="center" style="text-indent: 4em;">
                        ∟<span>企业新闻</span>
                    </td>
                    <td align="center">
                        <a href="__WEB__/index/channel/arclist/cid/{$s.id}" target="_blank">
                            <i class="icon icon-list-alt"></i>&nbsp;预览
                        </a>&nbsp;
                        <a href="__WEB__/index/channel/publish/cid/{$s.id}" target="_blank">
                            <i class="icon icon-share"></i>&nbsp;添加文章
                        </a>
                    </td>
                    <td align="center">
                        <a href="__CONTROL__/updateChannel?id={$s.id}" class="btn edit">
                            <i class="icon icon-edit"></i>&nbsp;修改
                        </a>&nbsp;
                        <a href="__CONTROL__/delChannel?id={$s.id}&pid={$s.pid}" class="isok btn del">
                            <i class="icon icon-trash"></i>&nbsp;删除
                        </a>
                    </td>
                </tr> 
            </foreach>
            <?php $i++;?>
        </foreach>
            <tr class="top_channel">
                <td></td>
                <td align="center">
                    <!-- <input type="hidden" name="table" value="channel"/>
                    <input type="submit" value="更新排序" class="sortsub"/> -->
                </td>
                <td colspan="2"></td>
            </tr>
        </tbody>
    </table>
</form>
<script>
    $('.table td strong').toggle(function(){
        var class_index = $(this).attr('index');
        $(' i',this).removeClass('icon-plus').addClass('icon-minus');
        $('.child_channel_'+class_index).fadeIn('slow');
    },function(){
        var class_index = $(this).attr('index');
        $('.child_channel_'+class_index).fadeOut('fast');
        $(' i',this).removeClass('icon-minus').addClass('icon-plus');
    });
        
    $('.display').live('click',function(){
        var id = $(this).attr('cnlid');
        var pid = $(this).attr('cnlpid');
        ajaxDisplay(id,pid,1,$(this),1);
    });
        
    $('.hidden').live('click',function(){
        var id = $(this).attr('cnlid');
        var pid = $(this).attr('cnlpid');
        ajaxDisplay(id,pid,0,$(this),1);
    });
        
    $('.ishigh').live('click',function(){
        var id = $(this).attr('cnlid');
        var pid = $(this).attr('cnlpid');
        ajaxDisplay(id,pid,1,$(this),2);
    });
        
    $('.nohigh').live('click',function(){
        var id = $(this).attr('cnlid');
        var pid = $(this).attr('cnlpid');
        ajaxDisplay(id,pid,0,$(this),2);
    });
        
    function ajaxDisplay(id,pid,display,obj,type){
        var offmsg = type == 1 ? '隐藏' : '正常';
        var offcss = type == 1 ? 'display' : 'ishigh';
        var oncss = type == 1 ? 'hidden' : 'nohigh';
        var onmsg = type == 1 ? '显视' : '飘红';
        var ajaxUrl = type == 1 ? 'ajaxDisplay' : 'ajaxHigh';
        var officon = type == 1 ? 'icon-eye-close' : 'icon-leaf';
        var onicon = type == 1 ? 'icon-eye-open' : 'icon-fire';
        var statusHtml = display?'<i class="icon '+officon+'"></i>&nbsp;'+offmsg:'<i class="icon '+onicon+'"></i>&nbsp;'+onmsg;
        var removeCss = display ? offcss : oncss;
        var addCss = display ? oncss : offcss;
        var tdtype = type == 1 ? '.dis' : '.hi';
        $.get('__CONTROL__/'+ajaxUrl,{'id':id,'pid':pid,'display':display},function(data){
            if (type == 1) {
                if (pid !=0) {
                    if (data.status) {
                        obj.removeClass(removeCss).addClass(addCss).html(statusHtml);
                    } else {
                        showTips(data.msg);
                    }
                } else {
                    if (data.status) {
                        obj.removeClass(removeCss).addClass(addCss).html(statusHtml);
                        $('.table '+tdtype+' span[cnlpid = '+id+']').removeClass(removeCss).addClass(addCss).html(statusHtml);
                    } else {
                        showTips(data.msg);
                    }
                }
            } else {
                if (data.status) {
                    obj.removeClass(removeCss).addClass(addCss).html(statusHtml);
                } else {
                    showTips(data.msg);
                }
            }
        },'json');
    }
</script>
</body>
</html>